<?php
/**
 *
 * 版权所有：顺势网站管理系统<www.51shunshi.com>

 * 日    期：2016-09-20
 * 版    本：1.0.0
 * 功能说明：文章控制器。
 *
 **/

namespace Qwadmin\Controller;

use Vendor\Tree;

class CommentController extends ComController
{
    public function index(){
        $p = isset($_GET['p']) ? intval($_GET['p']) : '1';
        $prefix= C("DB_PREFIX");
        $pagesize = 3;//每页数量
        $p = isset($_GET['p']) ? intval($_GET['p']) : '1';
        $count = M("comment")->count();

        $list = M("comment c")
            ->field("c.*,{$prefix}article.title")
            ->order("id desc")
            ->page($p, $pagesize)
            ->join("{$prefix}article ON {$prefix}article.aid = c.article_aid")
            ->select();
        $page = new \Think\Page($count, $pagesize);
        $page = $page->show();
        $this->assign('list', $list);
        $this->assign('page', $page);
        $this->assign(articlecon,$list);
        $this->assign(flag,$list['0']['name']);
        $this->display();
    }
    public function del(){
        if(IS_GET){
            $id = $_GET["id"];
            $del = M("comment")
                ->where("id = $id")
                ->delete();
            if($del){
                $this->success("删除成功");
            }else{
                $this->error("删除成功");
            }
        }
    }


}